/*
 ----------------------------------------------------------------------------------
                          "THE BEER-WARE COPYRIGHT LICENSE"
                                    (Revision 43)
                                     -----------
   Rymek [rymek@rymek.org] wrote this file. As long as You retain this notice and
   this file has been sent directly to You by the author, You can do whatever You
   want with this stuff as long as You don't sell or rent it. If we meet some day,
   and You think this stuff is worth it, You can buy me a beer in return :-)
                                                                __________
                                                                Paweł Rymaszewski
 ----------------------------------------------------------------------------------
 */

package ui.windows.components.panels.serverInformationPanel;

import ui.windows.forms.serverForm.ServerForm;

import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;

/**
 * Performs actions on ServerList combobox
 *
 * @author rymek
 *         User: rymek
 *         Date: 12.08.11
 *         Time: 11:52
 */
class ServerListKeyAdapter extends KeyAdapter {

    private final ServerInformationPanel serverInformationPanel;      // parent panel

    /**
     * Constructor.
     * Also sets reference to parent panel.
     *
     * @param serverInformationPanel parent panel
     */
    public ServerListKeyAdapter(ServerInformationPanel serverInformationPanel) {
        this.serverInformationPanel = serverInformationPanel;
    }

    /**
     * Performs click action on ServerForm
     *
     * @param e KeyEvent
     */
    @Override
    public void keyPressed(KeyEvent e) {
        super.keyPressed(e);
        if (e.getKeyCode() == KeyEvent.VK_ENTER) {
            ((ServerForm) this.serverInformationPanel.getParentFrame()).getConnectButton().doClick();
        }
    }
}
